package com.kaishengit.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.kaishengit.pojo.Info;
import com.kaishengit.pojo.Task;
import com.kaishengit.pojo.Type;
import com.kaishengit.pojo.User;
import com.kaishengit.service.InfoService;
import com.kaishengit.service.TaskService;
import com.kaishengit.service.TypeService;

public class LatestAction implements SessionAware{
	private List<Info> infos;
	private InfoService infoService;
	private Info info;
	private String infoid;
	private TypeService typeService;
	private List<Type> typelist;
	private Map<String,Object> session;
	private List<Task> tasklist;
	private TaskService taskService;
	
		public String execute(){
			infos=infoService.findAll();
						
			User u = (User) session.get("nowUser");
			String hql="from Type where userid=? and typea=?";
			typelist = typeService.find(hql,u.getId(),"taskstype");
			
			tasklist = taskService.findByUser(u.getId());
			return "success";
		}
		public String del(){
			System.out.println(infoid);
			info=infoService.findById(infoid);
			
			infoService.del(info);
			
			return "success";
		}
		
		
		
		
		//get set 
		
		public List<Info> getInfos() {
			return infos;
		}
		public String getInfoid() {
			return infoid;
		}
		public void setInfoid(String infoid) {
			this.infoid = infoid;
		}
		public Info getInfo() {
			return info;
		}
		public void setInfo(Info info) {
			this.info = info;
		}
		public void setInfos(List<Info> infos) {
			this.infos = infos;
		}
		public void setInfoService(InfoService infoService) {
			this.infoService = infoService;
		}
		public void setTypelist(List<Type> typelist) {
			this.typelist = typelist;
		}
		public List<Type> getTypelist() {
			return typelist;
		}
		public void setTypeService(TypeService typeService) {
			this.typeService = typeService;
		}
		
		public void setSession(Map<String, Object> session) {
			this.session=session;
			
		}
		public void setTasklist(List<Task> tasklist) {
			this.tasklist = tasklist;
		}
		public List<Task> getTasklist() {
			return tasklist;
		}
		public void setTaskService(TaskService taskService) {
			this.taskService = taskService;
		}
		
		
		
		
		
}
